import pytest


class TestBase:
    # @pytest.fixture(scope='class', autouse=True)  # 在 test_derived 中无法使用 self.base
    @pytest.fixture(scope='function', autouse=True)  # 可行
    def init(self):
        self.base = "base"


class TestDerived(TestBase):
    def test_derived(self):
        assert self.base == "base"

    def test_derived2(self):
        assert self.base == "base"
